<?php
if (isset($_GET['pw']) and $_GET['pw'] == 'ojiipwns'){
include('db.php');
$genres = ''
$query = 'SELECT genre FROM songlist';
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
    if (!strstr($row['genre'],$genres)){
    $genres = $genres . ';' . $row['genre'];
    }
}
$genrearray = explode(";", $genres);
foreach ($genrearray as $genre){
    $songidlist = '';
    $query = 'SELECT songid FROM songlist WHERE genre = "' . $genre . '"';
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
    {
        $songidlist = $songidlist . $row['songid'] . ',';
    }
    $songidlist = substr($songidlist,0,strlen($songidlist) -1);
    $query = 'INSERT INTO playlists (playlistname,songidlist,submitted) VALUES ("' . $genre . '","' . $songidlist . '",0)';
    mysql_query($query) or die(mysql_error());
    echo 'Added playlist: $genre<br>';
}
echo 'Done';
} else { die('hacker!!!!');}
?>